Structures are declared in a special section of your scripts, the TYPE block. This optional section, which is located between the
CONST and
VAR sections of the main program block, is the only location where structures may be declared. There is no limit to the number of structures that may be declared in a
TYPE block.
The declaration begins with the identifier used to refer to the structure. Following this identifier is the special symbol
= and the keyword
STRUCTURE, which indicates that the member declarations which follow should be grouped under the specified identifier name. The members of a structure are declared just as you would declare any other variable, with all the same rules for declaring variables applying to the member declarations. The structure declaration is terminated by using the
END keyword.
Structure declarations, unlike variables or constants, do not reserve storage space for data. Instead, they define a new data type which can be used in your scripts as you would any of the fundamental data types. Such a user-defined type can be used to declare variables or arrays in the same manner as using
INTEGER,
STRING, or other fundamental types.
The structure POINT contains two members of type
REAL, but no space is allocated until variables or arrays are declared using the structure as a user-defined type:
The centerPt and
target variables each contain storage for the two
REAL values contained within the structure, and the vertex_list array reserves sufficient memory to store twenty
POINT items, or forty
REAL values. The
POINT structure acts as a “template” to use when defining data value storage for your script.